package com.xjcs.saplingplan.ui.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.xjcs.saplingplan.ui.fragment.FocusFragment
import com.xjcs.saplingplan.ui.fragment.MineFragment
import com.xjcs.saplingplan.ui.fragment.PlanFragment

// ViewPagerAdapter.java
class ViewPagerAdapter(fragmentActivity: FragmentActivity) :
    FragmentStateAdapter(fragmentActivity) {

    override fun createFragment(position: Int): Fragment {
        return when (position) {
            0 -> PlanFragment()
            1 -> FocusFragment()
            2 -> MineFragment()
            3 -> MineFragment()
            4 -> MineFragment()
            else -> throw IllegalArgumentException("Invalid position: $position")
        }
    }

    override fun getItemCount(): Int {
        return NUM_TABS
    }

    companion object {
        private const val NUM_TABS = 5
    }
}